<template>
  <div class="Echarts">
    <div ref="main"
         style="width: 100%;height: 400px;"></div>
  </div>
</template>
 
<script>
export default {
  name: 'Echarts',
  methods: {
    myEcharts () {
      var myChart = this.$echarts.init(this.$refs.main);
      //配置图表
      var option = {
        title: {
          text: '当日消毒情况',
          subtext: '2022-02-07',
          left: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          left: 'left',
          data: ['已消毒', '未消毒']
        },
        series: [
          {
            name: '消毒情况',
            type: 'pie',
            radius: '55%',
            center: ['50%', '60%'],
            data: [
              { value: 335, name: '已消毒' },
              { value: 310, name: '未消毒' },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      myChart.setOption(option);
    }
  },
  mounted () {
    this.myEcharts();
  }
}
</script>
 
<style>
</style>